/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lose.ucm;

import lose.view.LoseReport;
import medium.MsgSender;

/**
 *
 * @author Donghui
 */

public class ChangeCard {

    private static ChangeCard local;
    private String sql;
    private String cid;
    private String pid;
    private String psw;
    private String msg;
    private int response;

    public static ChangeCard getInstance()
    {
        if(local==null)
        {
            local=new ChangeCard();
        }
        return local;
    }

    public void updateCard()
    {
        cid=LoseReport.getInstance().getValueModel().getCid();
        pid=LoseReport.getInstance().getValueModel().getPid();
        psw=LoseReport.getInstance().getValueModel().getNewPsw();

        msg=pid+";"+cid+";"+psw;
        MsgSender.getInstance().toUpdateCard(msg);
//        sql="DELETE FROM rfid WHERE roll_id='"+pid+"'";
//        Update.getInstance().updateValue(sql);
//        sql="UPDATE rfid,roll SET rfid.roll_id='"+pid+"',rfid.psw='"+psw+"',roll.card_id='"+cid+"' WHERE rfid.cid='"+cid+"' AND roll.id='"+pid+"'";
//        response=Update.getInstance().updateValue(sql);
//        if(response==1)
//        {
//            JOptionPane.showMessageDialog(null,"Updated successfully");
//        }
//        else
//        {
//            JOptionPane.showMessageDialog(null,"Failed to update");
//        }
    }

    

}
